﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using System.Web;
using log4net.Config;


namespace LogInformation
{
    enum logMode
    {
        FATAL = 0,
        ERROR,
        WARM,
        DEBUG,
        INFO,
        ALL,
    }
    class Log4Net
    {
        private static readonly log4net.ILog logger 
            = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        public Log4Net()
        {
            XmlConfigurator.Configure(new System.IO.FileInfo("log4net.xml"));
        }

        public static void WriteLogMessage(string msg, logMode mode = logMode.INFO)
        {
#if DEBUG
                Console.WriteLine(msg);
#endif
            switch (mode)
            {
                case logMode.FATAL: logger.Fatal(msg); break;
                case logMode.ERROR: logger.Error(msg); break;
                case logMode.WARM: logger.Warn(msg); break;
                case logMode.DEBUG: logger.Debug(msg); break;
                case logMode.INFO:
                case logMode.ALL: logger.Info(msg); break;
                default:
                    return;
            }
        }
    }
}